import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:lepig/common/config/theme.dart';

class MyOrder extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _MyOrder();
  }
}

class _MyOrder extends State<MyOrder> with  SingleTickerProviderStateMixin {

  List<String> Tabs = [
    "全部",
    "已付款",
    "已结算",
    "已失效",
  
  ];
  TabController _tabController;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController = TabController(length: Tabs.length, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
        title: new Text("我的订单"),
      ),

      body: new Column(
        children: <Widget>[
          new TabBar(
            controller: _tabController,
            tabs: Tabs.map((e){
              return new Tab(
                child: new Text(e),
              );
            }).toList(),
          ),
          Expanded(
            child:  new Container(
              color: curBgColor,
              child: _tabsView(),
            ),
          )
        ],
      ),
    );
  }

  Widget _tabsView(){
     return TabBarView(
      controller: _tabController,
      children: Tabs.map((type) {
        //创建3个Tab页
        return _tabCard(type);
      }).toList(),
    );
  }
  Widget _tabCard(i) {
    return new ListView(
      children: <Widget>[
        _item(),
        _item(),
        _item(),
        _item(),
        _item(),
        _item(),
        _item(),
        _item(),
        _item(),
        _item(),
        _item(),
        _item(),
      ],
    );
  }
  Widget _item() {
    return new Container(
      child: new Column(
        children: <Widget>[
         new Container(
           padding: EdgeInsets.all(10.0),
           child:  new Row(
             mainAxisAlignment: MainAxisAlignment.spaceBetween,
             children: <Widget>[
               new Text("淘宝",style: TextStyle(
                   fontSize: 16
               ),),
               new Text("2020-05-12 19:32:00",style: TextStyle(
                 color: Color.fromRGBO(144, 139, 139, 1),
                 fontSize: 13
               ),),
             ],
           ),
           color: Colors.white,
         ),
         new Padding(
           child:  new Flex(
             direction: Axis.horizontal,
             children: <Widget>[
               new Container(
                 width: 80.0,
                 margin: EdgeInsets.only(right: 10.0),
                 child: new ClipRRect(
                   borderRadius: BorderRadius.circular(10.0),
                   child: new Image.network("https://img.alicdn.com/bao/uploaded/i1/2206889475556/O1CN01nwgulh1quh7VRxrc0_!!0-item_pic.jpg",width: 50.0,),
                 ),
               ),
               new Expanded(
                 child: new Column(
                   crossAxisAlignment: CrossAxisAlignment.start,
                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
                   children: <Widget>[
                     new Container(
                       child:   new Text("【天猫旗舰店】儿童夏季防水无袖吃饭罩衫",maxLines: 2,overflow:TextOverflow.ellipsis,style: TextStyle(
                         fontSize: 15.0
                       ),),
                       height: 55.0,
                     ),
                     new Row(
                       mainAxisAlignment: MainAxisAlignment.spaceBetween,
                       children: <Widget>[
                         new Row(
                           children: <Widget>[
                             new Text("￥",style: TextStyle(
                               color: Colors.redAccent
                             ),),
                             new Text("58.25",style: TextStyle(
                                 color: Colors.redAccent,
                                fontSize: 18.0
                             ),)
                           ],
                         ),
                         new Container(
                           padding: EdgeInsets.only(left: 10,right: 10,top: 5,bottom: 5),
                           child: new Text("预计赚：￥1.25",style: TextStyle(
                             color: Colors.white,
                             fontSize: 12.0,
                           ),),
                           color: Colors.redAccent,
                         )
                       ],
                     )
                   ],
                 ),
               ),

             ],
           ),
           padding: EdgeInsets.all(10.0),
         ),
          new Container(
            padding: EdgeInsets.all(10.0),
            child:  new Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                new Text("订单号：151165959",style: TextStyle(
                    fontSize: 14
                ),),
                new Text(Tabs[1])
              ],
            ),
            color: Colors.white,
          ),
        ],
      ),

      margin: EdgeInsets.only(top: 20,bottom: 0.0),
      decoration: BoxDecoration(
        color: Color.fromRGBO(242, 242, 242, 1),

      ),
    );
  }

}
